DevForce Help Reference
FirstOrNullEntity<TEntity>(IQueryable<TEntity>,Expression<Func<TEntity,Boolean>>) Method
Example 


Executes the query and returns the first element of the sequence, or the appropriate NullEntity if no element is found.
Syntax
'Declaration
 
<ExtensionAttribute()>
Public Overloads Shared Function FirstOrNullEntity(Of TEntity As Class)( _
   ByVal source1 As IQueryable(Of TEntity), _
   ByVal predicate As Expression(Of Func(Of TEntity,Boolean)) _
) As TEntity
'Usage
 
Dim source1 As IQueryable(Of TEntity)
Dim predicate As Expression(Of Func(Of TEntity,Boolean))
Dim value As TEntity
 
value = EntityQueryExtensions.FirstOrNullEntity(Of TEntity)(source1, predicate)
[Extension()]
public static TEntity FirstOrNullEntity<TEntity>( 
   IQueryable<TEntity> source1,
   Expression<Func<TEntity,bool>> predicate
)
where TEntity: class

Parameters

source1
predicate

Type Parameters

TEntity
Example
var mgr1 = new DomainModelEntityManager();
Customer cust = mgr1.Customers.FirstOrNullEntity(c => c.Country == "UK");
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EntityQueryExtensions Class
EntityQueryExtensions Members
Overload List

Send Feedback